﻿using System;
using System.Net;
using Heimdallr.Net;

#if DEBUG
using System.IO;
using System.Diagnostics;
#endif

namespace Heimdallr.Sample.ChatRoom.Server
{
    class CustomPollingResponseModule : HttpPollingResponseModule
    {
        public CustomPollingResponseModule()
            : base(WebRequestMethods.Http.Get, "svc-bin/chatroom/response/polling/", HttpModuleCredentialType.None)
        {
            base.Duration = 15; // 15 sec.
            base.EmptyResponseStatusCode = HttpStatusCode.OK;
            base.EmptyResponseHeaders[HttpResponseHeader.CacheControl] = "no-cache";
        }

        protected override void ContextRegistered(HttpResponseContext response)
        {
            response.Headers[HttpResponseHeader.CacheControl] = "no-cache"; 
        }

        protected override object BeforePublish(HttpOperationDescription description, ref Notification notification)
        {
            Console.WriteLine("Ready to publish {0} data. Length: {1}", notification.ContentType, notification.ContentLength); 

            return base.BeforePublish(description, ref notification);
        }
    }
}